package com.wonders.ssm.service;

import com.wonders.ssm.dao.AuthUserMapper;
import com.wonders.ssm.dao.StudentMapper;
import com.wonders.ssm.pojo.AuthUser;
import com.wonders.ssm.pojo.Student;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by lv on 2018/7/31.
 */
@Service
public class StudentService {
    private Logger logger = Logger.getLogger(getClass());

    @Autowired
    private StudentMapper studentMapper;

    @Autowired
    private AuthUserMapper authUserMapper;

    public Student selectByPrimaryKey(String id){
        return studentMapper.selectByPrimaryKey(id);
    }

    public Integer addUser(Student student){
        int a = studentMapper.addUser(student);
        return a;
    }

    public Integer insertWage(Student student){
        int a = studentMapper.addUser(student);
        student.setId("1991");
        //int t = 1/0;
        int b = studentMapper.addUser(student);
        int c = 0;
        if(a==b && a== 1){
            c = 1;
        }
        return c;
    }

    public AuthUser login(String name,String password){
        AuthUser user = authUserMapper.login(name,password);
        return user;
    }
}
